package com.example.gaodetest;

import com.example.gaodetest.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.window.dialog.ToastDialog;
import ohos.bundle.IBundleManager;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbility extends Ability {

    private static final HiLogLabel hilog = new HiLogLabel(HiLog.DEBUG, 0x0000, "APP_LOG");

    public static final int LOCATION_PEEMISSION_CODE = MainAbilitySlice.MY_LOCATION_PERMISSION;

    private MainAbilitySlice mainAbilitySlice = new MainAbilitySlice();

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());
    }

    //调用requestPermissionsFromUser后的权限申请应答
    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode){
            case LOCATION_PEEMISSION_CODE: {
                if (grantResults.length > 0 && grantResults[0] == IBundleManager.PERMISSION_GRANTED){
                    new ToastDialog(getContext()).setText("权限被授予，可进行地图【定位】的显示和初始化").show();
                   
                 }else{
                    new ToastDialog(getContext()).setText("权限被拒绝").show();
                }
                return;
            }
        }
    }

}
